//
//  ChuanCaiController.m
//  DongChiDaChiProject1
//
//  Created by lanou3g on 15/10/28.
//  Copyright © 2015年 com.lanou3g. All rights reserved.
//

#import "ChuanCaiController.h"

@interface ChuanCaiController ()

@end

@implementation ChuanCaiController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addBar];
//    self.titleName = self.model.title;
    UIView *backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backView.backgroundColor = [[UIColor orangeColor]colorWithAlphaComponent:0.2];
    
    [self.view addSubview:backView];
    
    self.view.backgroundColor = [UIColor whiteColor];
    ChuanCaiView *chuanCaiView = [[ChuanCaiView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    chuanCaiView.bounces = NO; // 不允许反弹
    chuanCaiView.showsVerticalScrollIndicator = NO; // 不显示垂直滑动条
    [backView addSubview:chuanCaiView];
    chuanCaiView.titleLable.text = [NSString stringWithFormat:@" %@ ", self.model.title];
    chuanCaiView.categoryLable.text = self.model.category;
    chuanCaiView.imageThumb.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.model.thumb]]];
    
    NSString *astr = [self.model.yuanliao stringByReplacingOccurrencesOfString:@"<span>"withString:@": "];
    chuanCaiView.yuanliaoLable.text = [astr stringByReplacingOccurrencesOfString:@"</span>" withString:@" "];
//    CGRect newFrame1 = chuanCaiView.yuanliaoLable.frame;
//    newFrame1.size.height = [chuanCaiView viewWithModel:self.model];
//    chuanCaiView.yuanliaoLable.frame = newFrame1;
   
    NSString *astr1 = [self.model.yingyang stringByReplacingOccurrencesOfString:@"<p>"withString:@" "];
    NSString *str2 = [astr1 stringByReplacingOccurrencesOfString:@"                 "withString:@""];
    chuanCaiView.yingyangLable.text = [str2 stringByReplacingOccurrencesOfString:@"</p>" withString:@" "];
    
    chuanCaiView.yingyangLable.numberOfLines = 0;
    //chuanCaiView.yingyangLable.text = self.model.yingyang;
    CGRect newFrame = chuanCaiView.yingyangLable.frame;
    newFrame.size.height = [chuanCaiView viewWithModel:self.model];
    chuanCaiView.yingyangLable.frame = newFrame;
    
    
}

#pragma mark - 添加bar
- (void)addBar
{
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:@"川菜" style:UIBarButtonItemStylePlain target:self action:@selector(returnToLast:)];
    leftItem.tintColor = [UIColor colorWithHue:0.8 saturation:1 brightness:0.7 alpha:1];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    [self.navigationController.navigationBar setTranslucent:NO];
}

- (void)returnToLast:(UIBarButtonItem *)barItem
{
    [self.navigationController popViewControllerAnimated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
